package com.ruoyi.buss.grid.cj.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.grid.cj.domain.DataWgcjYzb;
import com.ruoyi.buss.grid.cj.service.IDataWgcjYzbService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 农村客户预值Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/cjyzb")
public class DataWgcjYzbController extends BaseController
{
    @Autowired
    private IDataWgcjYzbService dataWgcjYzbService;

    /**
     * 查询农村客户预值列表
     */
    @PreAuthorize(hasPermi = "buss:cjyzb:list")
    @GetMapping("/list")
    public TableDataInfo list(DataWgcjYzb dataWgcjYzb)
    {
        startPage();
        List<DataWgcjYzb> list = dataWgcjYzbService.selectDataWgcjYzbList(dataWgcjYzb);
        return getDataTable(list);
    }

    /**
     * 导出农村客户预值列表
     */
    @PreAuthorize(hasPermi = "buss:cjyzb:export")
    @Log(title = "农村客户预值", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataWgcjYzb dataWgcjYzb) throws IOException
    {
        List<DataWgcjYzb> list = dataWgcjYzbService.selectDataWgcjYzbList(dataWgcjYzb);
        ExcelUtil<DataWgcjYzb> util = new ExcelUtil<DataWgcjYzb>(DataWgcjYzb.class);
        util.exportExcel(response, list, "农村客户预值数据");
    }

    /**
     * 获取农村客户预值详细信息
     */
    @PreAuthorize(hasPermi = "buss:cjyzb:query")
    @GetMapping(value = "/{hjbh}")
    public AjaxResult getInfo(@PathVariable("hjbh") String hjbh)
    {
        return AjaxResult.success(dataWgcjYzbService.selectDataWgcjYzbById(hjbh));
    }

    /**
     * 新增农村客户预值
     */
    @PreAuthorize(hasPermi = "buss:cjyzb:add")
    @Log(title = "农村客户预值", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataWgcjYzb dataWgcjYzb)
    {
        return toAjax(dataWgcjYzbService.insertDataWgcjYzb(dataWgcjYzb));
    }

    /**
     * 修改农村客户预值
     */
    @PreAuthorize(hasPermi = "buss:cjyzb:edit")
    @Log(title = "农村客户预值", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataWgcjYzb dataWgcjYzb)
    {
        return toAjax(dataWgcjYzbService.updateDataWgcjYzb(dataWgcjYzb));
    }

    /**
     * 删除农村客户预值
     */
    @PreAuthorize(hasPermi = "buss:cjyzb:remove")
    @Log(title = "农村客户预值", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hjbhs}")
    public AjaxResult remove(@PathVariable String[] hjbhs)
    {
        return toAjax(dataWgcjYzbService.deleteDataWgcjYzbByIds(hjbhs));
    }
}
